package com.ziytek.web.citizen.model.data;

import lombok.Data;

import java.util.Comparator;
import java.util.List;


/**
 * @author fengh
 */
@Data
public class RealData {
    /**
     * 通讯头 1-字节 通信头 0xAA
     */
    private Integer h;

    /**
     * 通信板的地址 1-字节 0X00-0XFF
     */
    private Integer b;


    /**
     * 数据类型 1-字节 0X00-0XFF
     */
    private Integer t;


    /**
     * 数据负载 N-字节
     */
    private List<BatteryDetail> d;

    /**
     * 上送时间戳
     */
    private Long ts;

    /**
     * 原始数据字节数组
     */
    private byte[] bd;

    public RealData(byte[] baseDataBytes, Integer head, Integer boardAddress, List<BatteryDetail> loadData, Integer dataType) {
        this.h = head;
        this.d = loadData;
        this.t = dataType;
        this.b = boardAddress;
        this.bd = baseDataBytes;
        this.ts = System.currentTimeMillis();
        if (null != loadData) {
            this.d.sort(Comparator.comparing(BatteryDetail::getC));
        }
    }
}
